<template>
  <h1>todolist</h1>

  <input type="text" v-model="center"><button type="button" @click="tianjia">添加</button>
  <div v-for="(item, index) in mag" :key="index">
    <span @click="shanchu(index)">{{index+1}}.{{ item.mag }}</span>
  </div>
  <hr>

  <div v-for="(deletedItem,index) in centers" :key="index">
    <span>{{index+1}}.{{deletedItem.mag}}</span>
  </div>
</template>
<script>
// import tt1 from "@/components/tt1.vue";
// import index from "vuex";
export default {
  name: "Add",
  data(){
    return{
      center:'',
      mag:[],
      centers:[],
    }
  },

  methods:{
    tianjia(){
      this.mag.push({ mag: this.center });
      this.center = '';
    },
    shanchu(index){
      const deletedItem = this.mag.splice(index, 1);
      if (deletedItem) {
        this.centers.push(deletedItem[0]);}
    },
  }
}
</script>

<style scoped>

</style>